import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { LogisticsVO, LogisticsForm, LogisticsQuery } from '@/api/logistics/provider/types';

/**
 * 查询物流商列表
 * @param query
 * @returns {*}
 */
export const pageLogistics = (query?: LogisticsQuery): AxiosPromise<LogisticsVO[]> => {
  return request({
    url: '/oa/logistics/page',
    method: 'get',
    params: query
  });
};

/**
 * 查询物流商详细
 * @param logisticsId
 */
export const getLogistics = (logisticsId: string | number): AxiosPromise<LogisticsVO> => {
  return request({
    url: '/oa/logistics/' + logisticsId,
    method: 'get'
  });
};

/**
 * 新增物流商
 * @param data
 */
export const addLogistics = (data: LogisticsForm) => {
  return request({
    url: '/oa/logistics/add',
    method: 'post',
    data: data
  });
};

/**
 * 修改物流商
 * @param data
 */
export const updateLogistics = (data: LogisticsForm) => {
  return request({
    url: '/oa/logistics/edit',
    method: 'put',
    data: data
  });
};

/**
 * 删除物流商
 * @param logisticsId
 */
export const delLogistics = (logisticsId: string | number | Array<string | number>) => {
  return request({
    url: '/oa/logistics/' + logisticsId,
    method: 'delete'
  });
};

/**
 * 查询物流商列表
 * @param query
 * @returns {*}
 */
export const listLogistics = (query?: LogisticsQuery): AxiosPromise<LogisticsVO[]> => {
  return request({
    url: '/oa/logistics/list',
    method: 'get',
    params: query
  });
};
